#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;

struct coupon {
    long long bi;  // 满bi 减ci
    long long ci;
};

int main() {
    int n, m;
    cin >> n >> m;

    vector< long long > prices( n );
    for ( int i = 0; i < n; i++ ) {
        cin >> prices[ i ];
    }

    vector< coupon > m_coupons( m );
    for ( int i = 0; i < m; i++ ) {
        cin >> m_coupons[ i ].bi >> m_coupons[ i ].ci;
    }

    std::sort( m_coupons.begin(), m_coupons.end(), []( const coupon& a, const coupon& b ) { return a.ci > b.ci; } );

    long long res = 0;

    for ( int i = n - 1; i >= 0; i-- ) {
        int j = 0;

        for ( ; j < m; j++ ) {
            if ( prices[ i ] >= m_coupons[ j ].bi ) {
                res += prices[ i ] - m_coupons[ j ].ci;
                break;
            }
        }
        if ( j == m ) {
            res += prices[ i ];
        }
    }

    cout << res;
}